import { IConfig, IPlugin } from 'umi-types';
import { webpackPlugin } from './plugin.config';


const plugins: IPlugin[] = [
  './src/subAppPlugin.js',
  ['@umijs/plugin-qiankun', { slave: {} }],
  './src/subAppPlugin_next.js',
  [
    'umi-plugin-react',
    {
      antd: true,
      library: 'react',
      dva: false,
      locale: {
        enable: true,
        default: 'zh-CN',
        baseNavigator: true,
      },
      dynamicImport: {
        loadingComponent: './components/PageLoading/index',
        webpackChunkName: true,
        level: 3,
      },
      chunks: ['antdesigns', 'vendors', 'devextreme', 'defaultgroup', 'umi'], //'bryntum',
      // chunks: ['antdesigns', 'vendors', 'devextreme', 'default.umi', 'umi'],
      headScripts: process.env.SUB_APP === 'true'
        ? [] : [
          { src: '/Cesium/Cesium.js' },
          // { src: '/js/supermap/SuperMap.Include.js' },
          // { src: '/js/supermap/SuperMap-7.1-11828.js' },
          { src: '/js/config.js' },
          { src: '/gisJs/jquery.min.js' },
          { src: '/gisJs/CesiumHeatmap.js' },
          { src: '/gisJs/fly.js' },
        ],

      links: process.env.SUB_APP === 'true'
        ? [] : [{ rel: 'stylesheet', href: '/Cesium/Widgets/widgets.css' }],
    },
  ],
];

// 接口地址环境说明： .net/java 开发地址36，测试地址38，正式地址32
// 接口地址环境说明： usm服务 开发地址37，测试地址38，正式地址32

export default {
  plugins,
  hash: false,
  targets: {
    ie: 11,
  },
  ignoreMomentLocale: true,
  lessLoaderOptions: {
    javascriptEnabled: true,
  },
  disableRedirectHoist: true,
  manifest: {
    basePath: '/',
  },
  externals: {
    Cesium: 'window.Cesium',
    Fly_NZC: 'window.Fly_NZC',
    BMap: 'BMap',
  },
  chainWebpack: webpackPlugin,
  proxy: {
    '/rjApi/': {
      target: 'http://prp-test.cs.msdi.cn/',//平台组获取菜单的地址
      changeOrigin: true,
    },
    '/files/': {
      target: 'http://csfwq.msdi.cn:7000', //平台文件服务器地址
      pathRewrite: { '^/files': '' },
      changeOrigin: true,
    },
    '/api/Resource/': {
      // target: 'http://10.219.13.36:9017',  // .net资源模块地址
      target: 'http://10.219.13.38:9017',  // .net资源模块地址
      changeOrigin: true,
    },
    '/api/Material/': {
      // target: 'http://10.219.13.36:9017',// .net 设备物资 材料接口地址
      target: 'http://10.219.13.38:9017',// .net 设备物资 材料接口地址
      changeOrigin: true,
    },
    '/api/Project/': {
      // target: 'http://10.219.13.36:9010',// .net 项目基本信息
      target: 'http://10.219.13.36:9010',// .net 项目基本信息
      changeOrigin: true,
    },
    '/api/GeneralOffice/': {
      target: 'http://10.219.13.36:9012',// .net综合管理
      changeOrigin: true,
    },
    '/api/ProjectPlan/': {
      target: 'http://10.219.13.36:9013',// .net 项目策划
      changeOrigin: true,
    },
    '/api/Quality/': {
      target: 'http://10.219.13.36:9014',// .net 质量管理
      changeOrigin: true,
    },
    '/api/Schedule/': {
      target: 'http://10.219.13.36:9015',// .net 进度
      changeOrigin: true,
    },
    '/api/WBS/': {
      target: 'http://10.219.13.36:9016',// .net WBS
      changeOrigin: true,
    },
    '/api/Workflow/': {
      target: 'http://iwind.msdi.cn:5006/',// 平台流程接口地址，测试、开发公用地址
      changeOrigin: true,
    },

    '/api/Device/': {
      target: 'http://10.219.13.36:9011', // .net 设备物资
      changeOrigin: true,
    },
    '/api/usm/': {
      target: 'http://10.219.13.37:9997/microservices-usm-spring-cloud-starter',
      // target: 'http://10.219.13.38:9997/microservices-usm-spring-cloud-starter',
      pathRewrite: { '^/api/usm/': '/Api/usm/' },// 系统服务 开发地址
      changeOrigin: true,
    },
    '/api/contract/': {
      target: 'http://10.219.13.37:8888',  // java 合同模块 开发地址
      // target: 'http://10.219.13.38:8888',  // java 合同模块 开发地址
      // target: 'http://10.219.92.106:8888',  // 黄晶垚
      // target: 'http://10.219.243.101:8888',  // 谭凯
      // target: 'http://10.219.86.120:8888',  // 黄天昊
      // target: 'http://10.219.86.106:8888',  // 赵训卿
      changeOrigin: true,
    },

    '/api/design/': {
      target: 'http://10.219.13.37:8889',//java设计模块开发对应的接口地址
      changeOrigin: true,
    },
    '/api/cost/': {
      target: 'http://10.219.13.37:8887',  // java 成本模块 开发地址
      changeOrigin: true,
    },
    '/api/platform/': { //平台接口请求
      target: 'http://10.219.13.34:9989/',
      pathRewrite: { '^/api/platform/': '/Api/usm/' },
      changeOrigin: true,
    },
    '/api/setting/': { // 设置
      target: 'http://10.219.13.37:8890',
      // target: 'http://10.219.13.38:8890',
      pathRewrite: { '^/api/setting/': '/Api/usm/' },
      changeOrigin: true,
    },
    '/model/': {
      target: 'http://csfwq.msdi.cn:7000',
      pathRewrite: { '^/model': '' },
      changeOrigin: true,
    },
  },

  treeShaking: true,
} as IConfig;
